#!/usr/bin/python
# -*- coding: UTF-8 -*-

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D

# x = [1, 2, 3, 4, 5, 6]
# y = [5, 1, 2, 11, 5, 15]
# plt.scatter(x, y, marker='*', c='red')
# plt.show()

# y = x ** 2
# plt.plot(x, y, marker='o', c='blue')
# plt.show()

# x = np.linspace(-10, 10,100)
# y = x ** 2
# plt.plot(x, y, 'r--') # plot y = x^2
# plt.xlim(-10, 10) # set x range
# plt.ylim(0, 100) # set y range
# plt.xlabel('x') # set x label
# plt.ylabel('y') # set y label
# plt.title('y = x^2')
# plt.show()

# 3D plot
# z = np.square(x) + np.square(y)
# fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
# ax.scatter(x, y, z, c='r', marker='o')
# ax.set_xlabel('x')
# ax.set_ylabel('y')
# ax.set_zlabel('z')
# plt.show()

x = np.linspace(-10, 10, 100)
y = np.linspace(-10, 10, 100)
x, y = np.meshgrid(x, y)  # 生成网格数据
z = np.square(x) + np.square(y)

fig = plt.figure()  # 生成画布
ax = Axes3D(fig)  # 3D坐标轴
ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='rainbow')  # 绘制曲面图
# ax.set_xlabel('x')
# ax.set_ylabel('y')
# ax.set_zlabel('z')
plt.show()
